package com.my.htmlpdf;

import java.io.FileOutputStream;
import java.io.FileReader;
import java.util.ArrayList;

import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.html.simpleparser.HTMLWorker;
import com.lowagie.text.html.simpleparser.StyleSheet;
import com.lowagie.text.pdf.PdfWriter;

public class MainClass {
	public static void main(String[] args) throws Exception {
		Document document = new Document();
		StyleSheet st = new StyleSheet();
		st.loadTagStyle("body", "leading", "16,0");
		PdfWriter
				.getInstance(
						document,
						new FileOutputStream(
								"D:\\project\\simple_activiti\\src\\main\\webapp\\WEB-INF\\pages\\html-pdf.pdf"));
		document.open();
		ArrayList p = HTMLWorker
				.parseToList(
						new FileReader(
								"D:\\project\\simple_activiti\\src\\main\\webapp\\WEB-INF\\pages\\html-pdf.html"),
						st);
		for (int k = 0; k < p.size(); ++k){
			document.add((Element) p.get(k));
		}
		document.close();
	}
}